# coding: utf-8
import os
from pyhdf.SD import SD
from osgeo import gdal
import numpy as np
from pymodis import convertmodis_gdal
import pymodis

MODIS_FILE_DIR = 'F:/16satellite/data/test/'
out_pre = 'F:/16satellite/data/output/create/2007001.tif'
in_file = 'F:/16satellite/data/test/MOD13Q1.A2007001.h25v05.006.2015160165552.hdf'


def main():
    List = os.listdir(MODIS_FILE_DIR)
    hdfList = [MODIS_FILE_DIR + i for i in List]
    subset = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

    # aa = pymodis.convertmodis_gdal.convertModisGDAL(
    #     in_file, out_pre, subset, 0, outformat='GTiff', epsg=4326, wkt=None, resampl='NEAREST_NEIGHBOR',vrt=False)
    # aa.run()

    mosaic = pymodis.convertmodis_gdal.createMosaicGDAL(
            hdfList, subset=subset, outformat='GTiff')
    mosaic.run(out_pre)
    # mosaic.write_vrt('2007001.mosaci')


if __name__ == '__main__':
    main()
